package com.hr.剑指offer.work1;

/**
 * @author 周恒哲
 * @date 2020/06/12
 * 动态规划
 **/
public class 面试题10_1_斐波那契数列 {
    public static int fib(int n) {
        if(n==0){
            return 0;
        }
        int[] dp =new int[n+1];
        dp[0]=0;
        dp[1]=1;
        for (int i = 2; i < n+1; i++) {
            dp[i]=dp[i-1]+dp[i-2];
            dp[i]%=1000000007;
        }
        return dp[n];
    }

    public static void main(String[] args) {
        System.out.println(面试题10_1_斐波那契数列.fib(5));
    }
}
